import request from '@/utils/request'

// 查询产品管理列表
export function listProducts(query) {
  return request({
    url: '/commodity/products/list',
    method: 'get',
    params: query
  })
}

// 查询产品管理详细
export function getProducts(id) {
  return request({
    url: '/commodity/products/' + id,
    method: 'get'
  })
}


// 新增产品管理
export function addProducts(data) {
  return request({
    url: '/commodity/products',
    method: 'post',
    data: data
  })
}

// 修改产品管理
export function updateProducts(data) {
  return request({
    url: '/commodity/products',
    method: 'put',
    data: data
  })
}

// 停用产品管理
export function disableProducts(ids) {
  return request({
    url: '/commodity/products/disable',
    method: 'put',
    data: ids
  })
}

// 启用产品管理
export function enableProducts(ids) {
  return request({
    url: '/commodity/products/enable',
    method: 'put',
    data: ids
  })
}


// 查询部门下拉树结构
export function productTreeSelect() {
  return request({
    url: '/commodity/products/productTree',
    method: 'get'
  })
}

// 查询oem下拉树结构
export function oemTreeSelect() {
  return request({
    url: '/commodity/products/oemTree',
    method: 'get'
  })
}

// 生成sku
export function productsSkuName(oem) {
  return request({
    url: '/commodity/products/skuName/' + oem,
    method: 'get'
  })
}

// 查询所以的颜色
export function selectColorId() {
  return request({
    url: '/commodity/products/selectColor',
    method: 'get'
  })
}

// 根据id查询颜色
export function selectColorByIds(id) {
  return request({
    url: '/commodity/products/selectColorById/' + id,
    method: 'get'
  })
}

// 查询所以的品牌
export function selectBrand() {
  return request({
    url: '/commodity/products/selectBrand',
    method: 'get'
  })
}

// 查询店铺要关联的商品
export function selectProductBrand(query) {
  return request({
    url: '/commodity/products/selectProductBrand',
    method: 'get',
    params: query
  })
}

// 查询销售订单下的商品
export function selectByPlanId(query, isEdit) {
  return request({
    url: '/commodity/products/selectByPlanId',
    method: 'get',
    params: {
      ...query,
      isEdit,
    }
  })
}

//导入产品表格数据
export function importProductExcel(data) {
  return request({
    url: '/commodity/products/importProductExcel',
    method: 'post',
    data: data
  })
}

//查询品牌
export function selectById(id) {
  return request({
    url: '/commodity/products/selectById/' + id,
    method: 'get'
  })
}

